const vm = new Vue({
    el: '#main',
    data: {
        houseId: fxj.getSearch().get('houseId'),
        rule: {
            dayLeast: '',
            dayPrice: '',
            sevenRebate: '',
            thirtyRebate: '',
        },
    },
    methods: {},
});

function apiready() {
    fxj.fixLayout();
    reqMoreSettingInfo();

}

async function reqMoreSettingInfo() {
    const res = await ajax({
        url: 'home/houseManage/getHousePriceRule',
        data: {
            houseId: vm.houseId,
        },
    });
    if (res.err === 0) {
        res.data.sevenRebate = Number(res.data.sevenRebate) === 0 ? '' : res.data.sevenRebate;
        res.data.thirtyRebate = Number(res.data.thirtyRebate) === 0 ? '' : res.data.thirtyRebate;
        res.data.dayLeast = Number(res.data.dayLeast) === 0 ? '' : res.data.dayLeast;
        vm.rule = res.data;
    }
    else {
        toast(res.msg);
    }
}

async function save() {
    const close = fxj.dialog.loading({noBg: true});
    const res = await ajax({
        url: 'home/houseManage/modifyHousePrice',
        data: {
            houseId: vm.houseId,
            price: vm.rule.dayPrice,
            seven: vm.rule.sevenRebate ? vm.rule.sevenRebate : -1,
            thirty: vm.rule.thirtyRebate ? vm.rule.thirtyRebate : -1,
            least: vm.rule.dayLeast ? vm.rule.dayLeast : -1,
        },
    });
    close();
    toast(res.msg);
    if (res.err === 0) {
        setTimeout(() => {
            history.back();
        }, 1000);
    }
}